package com.chenfan.magic.service.impl;

import com.chenfan.magic.entity.Status;
import com.chenfan.magic.service.IStatusService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 状态码获取
 *
 * @author 周夕
 * @date 2020-02-15 18:16
 */
@Component
@AllArgsConstructor
public class StatusComponent {

    private IStatusService statusService;

    public Status def() {
        Status status = new Status();
        status.setStatusCode(9999999);
        status.setStatusMsg("状态码表异常, 请联系开发商!");
        return status;
    }

    public Status get(String index) {
        Status status = statusService.getById(index);
        if (status == null) {
            return def();
        }
        return status;
    }

}
